package main.Trees;

import sun.misc.GC;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import java.awt.*;

public class TreeHeaderRenderer extends JPanel implements TableCellRenderer {

    private static final Color COLOR_1 = new Color(255, 255, 255, 255);
    private static final Color COLOR_2 = new Color(94, 215, 4, 200);
    private static final float SIDE = 50;
    private GradientPaint gradientPaint = new GradientPaint(0, 10, COLOR_1, 0, 30, COLOR_2, true);
    private JLabel label = new JLabel();

    public TreeHeaderRenderer() {
        setOpaque(true);
        setLayout(new BorderLayout());
        add(label, BorderLayout.CENTER);
        label.setHorizontalAlignment(SwingConstants.CENTER);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
                                                   boolean isSelected, boolean hasFocused, int arg4, int arg5) {
        label.setText(value.toString());
        return this;
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        g2.setPaint(gradientPaint);
        g2.fillRect(0, 0, getWidth(), getHeight());
    }

}